package com.suixun.controller.credits;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.authority.controller.BaseManager;
import com.suixun.service.credits.PutGoodsService;
import com.suixun.util.Constant;

/**
 * <p>
 * Title: SendGoodsController
 * </p>
 * <p>
 * 功能描述: 配券
 * </p>
 * 
 * @author 陈显强
 * @date 2017年12月12日上午10:54:53
 * @version 1.0
 */
@RestController
@RequestMapping(value = "/credits/putGoods")
public class PutGoodsController extends BaseManager {

	@Autowired
	private PutGoodsService putGoodsService;

	/**
	 * 
	 * <p>
	 * Title: putGoodsRegions
	 * </p>
	 * <p>
	 * 功能描述: 按地区配券
	 * </p>
	 * 
	 * @param uuid
	 * @param goodsNumbers
	 * @param range
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/putGoodsRegions.json")
	public Object putGoodsRegions(String uuid, String goodsNumbers, Integer range) {
		try {
			putGoodsService.putGoodsRegions(uuid, goodsNumbers, range);
		} catch (Exception e) {
			e.printStackTrace();
			return fail(e.getMessage());
		}
		return success();
	}

	/**
	 * 
	 * <p>
	 * Title: pagePutGoods
	 * </p>
	 * <p>
	 * 功能描述: 查询投放优惠券列表
	 * </p>
	 * 
	 * @param page
	 * @param size
	 * @param goodsName
	 * @param goodsNumber
	 * @param uuid
	 * @param range
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/pagePutGoods.json")
	public Object pagePutGoods(int page, int size, String goodsName, String goodsNumber, String uuid, Integer range) {
		try {
			return success(putGoodsService.pagePutGoods(page, size, goodsName, goodsNumber, uuid, range));
		} catch (Exception e) {
			e.printStackTrace();
			logger("PutGoodsController pagePutGoods:" + e.getMessage(), e);
			return fail(Constant.EXCEPTION.OPERATE_FAIL);
		}
	}

	/**
	 * <p>Title: del</p>
	 * <p> 功能描述: 删除</p>
	 * @param putIds
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/del.json")
	public Object del(String putIds) {
		try {
			putGoodsService.del(putIds);
		} catch (Exception e) {
			return fail(e.getMessage());
		}
		return success();
	}
}
